package com.tebiecloud.order.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tebiecloud.order.client.model.entity.OrderGoods;
import com.tebiecloud.order.client.model.entity.OrderRefund;
import com.tebiecloud.order.server.mapper.OrderRefundMapper;
import com.tebiecloud.order.server.service.OrderRefundService;
import com.tebiecloud.common.mybatis.base.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 订单退款信息 服务实现类
 * @author tebie
 * @date 2019-09-17
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class OrderRefundServiceImpl extends BaseServiceImpl<OrderRefundMapper, OrderRefund> implements OrderRefundService {

    @Override
    public OrderRefund getLastOne(long orderId, int status) {
        QueryWrapper<OrderRefund> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("order_id", orderId);
        if(status >= 0) {
            queryWrapper.eq("status", status);
        }
        queryWrapper.orderByDesc("ct");
        return super.getOne(queryWrapper, false);
    }

}
